package com.onlineMIS.ORM.DAO.headQ.finance;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.poi.hssf.record.PageBreakRecord.Break;
import org.apache.struts2.util.Counter;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.onlineMIS.ORM.DAO.BaseDAO;
import com.onlineMIS.ORM.entity.base.BaseOrder;
import com.onlineMIS.ORM.entity.headQ.finance.ExpenseHqType;
import com.onlineMIS.ORM.entity.headQ.finance.FinanceBill;
import com.onlineMIS.ORM.entity.headQ.finance.FinanceBillCorpFlow;
import com.onlineMIS.ORM.entity.headQ.finance.FinanceBillCorpFlowVO;
import com.onlineMIS.ORM.entity.headQ.user.UserInfor;
import com.onlineMIS.common.Common_util;


@Repository
public class FinanceBillCorpFlowImpl extends BaseDAO<FinanceBillCorpFlow>{

	
	


	/**
	 * 有效表单更新数据的更新
	 * @param flow
	 * @param financeBillCorpFlow
	 */
	public void copyInfor(FinanceBillCorpFlow des, FinanceBillCorpFlow src) {
		des.setStatus(src.getStatus());
		des.setAmount(src.getAmount());
		des.setComment(src.getComment());
		des.setDate(src.getDate());
		des.setFromAcctId(src.getFromAcctId());
		des.setToAcctId(src.getToAcctId());
		des.setLastUpdateDate(new Date());
		
	}

	/**
	 * 根据卡号,查询流水记录
	 * @param cardId
	 * @param startTime
	 * @param endTime
	 * @return
	 */
	public List<FinanceBillCorpFlow> selectByCardId(int cardId, Date startTime, Date endTime) {
		DetachedCriteria criteria = DetachedCriteria.forClass(FinanceBillCorpFlow.class);
		criteria.add(Restrictions.or(Restrictions.eq("fromAcctId.id", cardId), Restrictions.eq("toAcctId.id", cardId)));
		criteria.add(Restrictions.eq("status",BaseOrder.STATUS_COMPLETE));
		criteria.add(Restrictions.between("date", startTime,endTime));
		List<FinanceBillCorpFlow> flows =  getByCritera(criteria, false);
		return flows;
	}

	
}
